@extends('home.userinfo.user_layout')
@section('title',$title)
@section('content')

	<div id="container">
    <div class="w">
    	<div id="content">
    		<input type="hidden" id="whereFrom" value="">
	        <div id="sub">
	      		<div id="menu">	
	      		<dl class="fore1">		
	      		<dt id="_MYJD_setting">设置</dt>		
	      		<dd class="fore1_1" id="_MYJD_info">			
	      		<a clstag="homepage|keycount|home2013|Homeyser" href="/user" target="_self">个人信息</a>		
	      		</dd>		
	      		<dd class="fore1_2" id="_MYJD_safe">			
	      		<a clstag="homepage|keycount|home2013|Homesafe" href="#" target="_self">账户安全</a>		
	      		</dd>		
	      		<dd class="fore1_3" id="_MYJD_accbinde">			
	      		<a clstag="homepage|keycount|home2013|Homezhbd" href="#" target="_self">账号绑定</a>		
	      		</dd>		
	      		<dd class="fore1_4" id="_MYJD_grade">			
	      		<a clstag="homepage|keycount|home2013|Homegrade" href="/dingdan" target="_self">我的订单</a>		
	      		</dd>		
	      		<dd class="fore1_5 curr" id="_MYJD_comments">			
	      		<a clstag="homepage|keycount|home2013|homeadd" href="/address" target="_self">收货地址</a>		
	      		</dd>	
	      		</dl>
	      		</div>
	      		<div id="menu-ads">
			
			<!--广告-->
				<div>
			<!-- 	<a href="#" target="_blank"><img width="90" height="70" alt="" app="image:poster" src="{{asset('/public/home/img/gg1.gif')}}">
				</a> -->

				</div>

				<div>
				<!-- <a href="#" target="_blank"><img width="90" height="70" alt="" app="image:poster" src="{{asset('/public/home/img/gg2.jpeg')}}"></a> -->
				</div>

				</div>
	        </div>
	        <div id="main">
	                <div id="addressList" class="mod-main mod-comm">



	                
	    				<div class="mt">
	<a  id="new_address" class="e-btn add-btn btn-5" href="javascript:;">新增收货地址</a>
	<!-- <span class="ftx-03">您已创建<span id="addressNum_top" class="ftx-02">0 </span>个收货地址，最多可创建<span class="ftx-02">20</span>个</span> -->
	<span class="ftx-03"><span id="addressNum_top" class="ftx-02"></span><span class="ftx-02"></span></span>
</div>

	<!-- =====收货地址信息开始======= -->
	@foreach($data as $d)
	<div class="sm easebuy-m " id="addresssDiv-138266354" style="border: 2px solid #e6e6e6;width:820px;height:190px;">
	<div class="detail_close_btn" style="width:25px;height:25px;color:#333;float:right;line-height:25px;text-align:center;font-size:22px;cursor:pointer;border:1px solid #ddd;"><a href="/address/del/{{$d -> id}}">╳</a></div>
	<div class="smc" style="margin-top:30px;margin-left:25px;">
				<div class="items new-items">
<input type="hidden" name="id" value="{{$d -> id}}">
					<div class="item-lcol" style="float:left;">
                    	<div class="item">
							<span class="label" font-size="60px">收货人：{{$d -> utname}}</span>
							<div class="fl">
                            
							</div>
							<div class="clr" style="width:100%;height:10px;"></div>
						</div>
                  
                        <div class="item">
							<span class="label">地址：{{$d -> address}}</span>
							<div class="fl">
                            	
							</div>
							<div class="clr" style="width:100%;height:10px;"></div>
						</div>
						<div class="item">
							<span class="label">手机：{{$d -> uphone}}</span>
							<div class="fl">
                            	
							</div>
							<div class="clr" style="width:100%;height:10px;"></div>
						</div>
                 
                        <div class="item">
							<span class="label">邮编：{{$d -> post}}</span>
							<div class="fl">
                            	
							</div>

							<div class="clr" style="width:100%;height:10px;"></div>
						</div>
					</div>


				<div class="item-rcol" style="float:right;margin-top:130px;margin-right:20px;">
					<div class="extra">
						<a class="ml10 ftx-05" href="javascript:makeAddressAllDefault('138266354');">设为默认</a>
						<a class="ml10 ftx-05" href="javascript:getPayment(138266354,0,0);">使用一键购</a>
						<a class="ml10 ftx-05" href="/address/edit/{{$d -> id}}" id="edit">编辑</a>
					</div>
				</div>

				<div class="clr" style="width:100%;height:10px;"></div>
				</div>
			</div>
	</div>
@endforeach
<!-- =====收货地址信息结束======= -->


<!-- =======添加收货地址弹出框=开始======= -->
<div id="add_address_box" style="display:none;width:600px;border:1px solid #ddd;position:fixed;top:100px;left:250px;background:#fff;z-index:9999;color:#999;">
		<div class="close_btn" style="width:25px;height:25px;color:#333;float:right;line-height:25px;text-align:center;font-size:22px;cursor:pointer;border:1px solid #ddd;">╳</div>
		<div class="box" style="width:550px;margin:0px auto;">
			
			<form id="add_address" action="" method="post">
			{{csrf_field()}}
			<input type="hidden" name="uid" value="{{$user -> id}}">
			<div class="box_top" style="width:800px;height:50px;line-height:70px;text-indent:10px;font-size:18px;color:#aaa;">添加收货地址</div>
			<ul style="width:550px;">
				<li style="width:550px;height:50px;border:1px solid #f7f7f7;margin-top:5px;line-height:50px;text-indent:50px;">
				<span style="color:#e4393c">*</span>　
				收货人：<input class="box_inp" type="text" name="utname"  style="width:350px;height:30px;border:0px solid #ddd;"/>
				</li>

				<li style="width:550px;height:50px;border:1px solid #f7f7f7;margin-top:5px;line-height:50px;text-indent:50px;">
				<span style="color:#e4393c">*</span>　
				详细地址：<input class="box_inp" type="text" name="address" style="width:350px;height:30px;border:0px solid #ddd;" />
				</li>
				<li style="width:550px;height:50px;border:1px solid #f7f7f7;margin-top:5px;line-height:50px;text-indent:50px;">
				<span style="color:#e4393c">*</span>	
				手机号码：<input class="box_inp" type="text" name="uphone"  id="uphone" style="width:350px;height:30px;border:0px solid #ddd;" />
				</li>
				<span style="text-indent:50px;color:#e4393c;display:none;" id="phone1">手机号码格式不正确</span>
				<span style="text-indent:50px;color:#e4393c;display:none;" id="phone2" >手机号码格式正确</span>

				<li style="width:550px;height:50px;border:1px solid #f7f7f7;margin-top:5px;line-height:50px;text-indent:50px;">
				<span style="color:#e4393c">*</span>　
				邮　编：<input class="box_inp" type="text" name="post"  style="width:350px;height:30px;border:0px solid #ddd;"/>
				</li>
			</ul>
			<div class="box_foot" style="width:550px;height:50px;margin-top:50px;">
			<div class="box_btn" style="width:120px;height:35px;border:1px solid #BFD6AF;float:right;font-size:18px;background:#EEF8E7;line-height:35px;text-align:center;cursor:pointer;border-radius:10px;" >
			保存收货地址
			</div>
			</div>
			</form>
		</div>
	</div>
<!-- =======添加收货地址弹出框结束======== -->
</div></div>
</div></div>
</div></div>


<!-- ======编辑地址框开始======== -->

<!-- ========编辑地址框结束========= -->

<!-- =======jquery===== -->
<script type="text/javascript">
//====添加开始======
		//弹出添加地址框
		$("#new_address").click(function(){
				//alert(1);
		    $("#add_address_box").css("display","block");
			$("#add_address_box").val() = "";
		});
		//关闭按钮
		$(".close_btn").click(function(){
			$("#add_address_box").css("display","none");
		});

		//提交数据
		$(".box_btn").click(function(){
			var address_data = $("#add_address").serialize();
			$.ajax({
				url:"/send_address",
			    type:"post",
				dataType:"json",
				async:true,
				data:address_data,
				success:function(data){
				    if(data==1){
						alert("添加成功！");
						$("#add_address_box").css("display","none");
						window.location.reload();
					}else{
						alert("添加失败！");
					}
				}
			});
		});
//====添加结束=======

//======删除开始======
		$('.detail_close_btn').on('click',function()
		{
			alert('您确定要删除该收货地址吗?');
		});
//======删除结束======

//====手机号码ajax判断===
 $("input[name='uphone']").on('blur',function()
    {
        $.post('/address/uphone',{'_token':'{{csrf_token()}}','uphone':$("#uphone").val()},function(data)
        {
            if(data == 2)
            {
                $("#phone1").css("display","block");
                $("input[name='uphone']").on('focus',function(){
                     $("#phone1").css("display","none");
                });
            }else if(data == 1){
                $("#phone2").css("display","block");
                 $("input[name='uphone']").on('focus',function(){
                     $("#phone2").css("display","none");
                });
            }
        });
    });

</script>
@endsection